<include file="public:header" />
<include file="public:left" />

<body style="background-color: rgb(255, 255, 255); overflow: auto; cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
	<div class="flexigrid">
		<div class="mDiv">
			<div class="ftitle">
				<h3>订单列表</h3>
				<h5>(共{$count}条记录)</h5>
			</div>
			<div title="刷新数据" class="pReload"><i class="fa fa-refresh"></i></div>
			<form class="navbar-form form-inline"  method="get" action=""  name="search-form2" id="search-form2">
				<input type="hidden" name="order_by" value="order_id">
				<input type="hidden" name="sort" value="desc">
				<div class="sDiv">
					<div class="sDiv2">
						<input type="text" size="30" id="add_time_begin" name="starttime" class="qsbox"  placeholder="下单开始时间" value="{$starttime}">
					</div>
					<div class="sDiv2">
						<input type="text" size="30" id="add_time_end" name="endtime"  class="qsbox"  placeholder="下单结束时间" value="{$endtime}">
					</div>
					<div class="sDiv2">
						<select name="status" class="select" style="width:100px;margin-right:5px;margin-left:5px">
							<option value=""  >订单状态</option>
							<option value="0" <eq name="status"	value="0">selected</eq>>待支付</option>
							<option value="1" <eq name="status"	value="1">selected</eq>>已支付</option>
							<option value="2" <eq name="status"	value="2">selected</eq>>待处理</option>
							<option value="3" <eq name="status"	value="3">selected</eq>>已完成</option>
						</select>
					</div>
					<div class="sDiv2">
						<select name="type" class="select" style="width:100px;margin-right:5px;margin-left:5px">
							<option value="" >订单类型</option>
							<option value="1" <eq name="type"	value="1">selected</eq>>预约</option>
							<option value="2" <eq name="type"	value="2">selected</eq>>店内送</option>
							<option value="3" <eq name="type"	value="3">selected</eq>>扫码点餐</option>
						</select>
					</div>
					<div class="sDiv2">
						<input type="text" size="30" name="keywords" class="qsbox" placeholder="搜索相关数据...">
					</div>
					<div class="sDiv2">
						<input type="submit"   class="btn" value="搜索">
					<!--	<input type="submit" name="export"   class="btn" value="导出">-->
					</div>
				</div>
			</form>
		</div>
		<div class="hDiv">
			<div class="hDivBox" id="ajax_return">
				<table cellspacing="0" cellpadding="0">
					<thead>
					<tr>
						<th class="sign" axis="col0">
							<div style="width: 24px;"><i class="ico-check"></i></div>
						</th>
						<th align="left" abbr="order_sn" axis="col3" class="">
							<div style="text-align: left; width: 140px;" class="">订单编号</div>
						</th>
						<th align="left" abbr="consignee" axis="col4" class="">
							<div style="text-align: left; width: 150px;" class="">会员资料</div>
						</th>
						<th align="center" abbr="article_show" axis="col5" class="" >
							<div style="text-align: center; width: 60px;" class="">总金额</div>
						</th>
						<th align="center" abbr="article_time" axis="col6" class="">
							<div style="text-align: center; width: 60px;" class="">订单类型</div>
						</th>
						<th align="center" abbr="article_time" axis="col6" class="">
							<div style="text-align: center; width: 60px;" class="">订单状态</div>
						</th>
						<th align="center" abbr="article_time" axis="col6" class="" s>
							<div style="text-align: center; width: 60px;" class="">支付方式</div>
						</th>
						<th align="center" abbr="article_time" axis="col6" class="" >
							<div style="text-align: center; width: 60px;" class="">抵扣金额</div>
						</th>
						<th align="center" abbr="article_time" axis="col6" class="" >
							<div style="text-align: center; width: 60px;" class="">抵扣方式</div>
						</th>
						<th align="center" abbr="article_time" axis="col6" class="">
							<div style="text-align: center; width: 120px;" class="">下单时间</div>
						</th>
						<th align="center" abbr="article_time" axis="col6" class="">
							<div style="text-align: center; width: 120px;" class="">预约时间</div>
						</th>
						<th align="center" abbr="article_time" axis="col6" class="">
							<div style="text-align: center; width: 120px;" class="">完成时间</div>
						</th>
						<th align="center" abbr="article_time" axis="col6" class="">
							<div style="text-align: center;" class="">备注</div>
						</th>
						<th align="left" axis="col1" class="handle">
							<div style="text-align: left; width: 150px;">操作</div>
						</th>
					</tr>
					</thead>
				</table>
			</div>
		</div>

		<div class="bDiv" style="height: auto;">
			<div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
				<table>
					<tbody>
					<if condition="empty($list) eq true">
						<tr data-id="0">
							<td class="no-data" align="center" axis="col0" colspan="50">
								<i class="fa fa-exclamation-circle"></i>没有符合条件的记录
							</td>
						</tr>
						<else/>
						<volist name="list" id="list">
							<tr data-order-id="{$list.id}">
								<td class="sign" axis="col0" style="text-align: left; width: 20px;" >
									<div style="width: 24px;"><i class="ico-check"></i></div>
								</td>
								<td align="left" abbr="order_sn" axis="col3" class="" style="text-align: left; width: 130px;" >
									<div style="text-align: left; width: 130px;" class="">{$list.order_sn}</div>
								</td>
								<td align="left" abbr="consignee" axis="col4" class="" style="text-align: left; width: 150px;" >
									<div style="text-align: left; width: 150px;" class="">{$list.nickname} {$list.mobile}</div>
								</td>
								<td align="center" abbr="article_show" axis="col5" class="" style="text-align: center; width: 60px;">
									<div style="text-align: center; width: 60px;" class="">{$list.total_price}</div>
								</td>
								<td align="center" abbr="article_time" axis="col6" class="" style="text-align: center; width: 60px;">
									<div style="text-align: center; width: 60px;" class="">
										<switch name="$list['type']" value="1">
											<case value="1"><span style="color: red">预约</span></case>
											<case value="2"><span style="color: red">送</span></case>
											<case value="3"><span style="color: red">扫码</span></case>
										</switch>
									</div>
								</td>
								<td align="center" abbr="article_time" axis="col6" class="" style="text-align: center; width: 60px;">
									<div style="text-align: center; width: 60px;" class="">
										<switch name="$list['status']" value="1">
											<case value="0"><span style="color: red">待支付</span></case>
											<case value="1"><span style="color: red">待处理</span></case>
											<case value="2"><span style="color: red">待完成</span></case>
										</switch>
									</div>
								</td>
								<td align="center" abbr="article_time" axis="col6" class="" style="text-align: center; width: 60px;">
									<div style="text-align: center; width: 60px;" class="">{$pay_type[$list['pay_type']]}</div>
								</td>
								<td align="center" abbr="article_time" axis="col6" class="" style="text-align: center; width: 60px;">
									<div style="text-align: center; width: 60px;" class="">{$list['discount']}</div>
								</td>
								<td align="center" abbr="article_time" axis="col6" class="" style="text-align: center; width: 80px;">
									<div style="text-align: center; width: 80px;" class="">{$list['discount_title']}</div>
								</td>
								<td align="center" abbr="article_time" axis="col6" class="" style="text-align: center; width: 120px;">
									<div style="text-align: center; width: 120px;" class=""><gt name="list.create_time" value="0">{$list.create_time|date='Y-m-d H:i',###}</gt></div>
								</td>
								<td align="center" abbr="article_time" axis="col6" class="" style="text-align: center; width:120px;">
									<div style="text-align: center; width: 120px;" class=""><gt name="list.book_time" value="0">{$list.book_time|date='Y-m-d H:i',###}</gt></div>
								</td>
								<td align="center" abbr="article_time" axis="col6" class="" style="text-align: center; width:120px;">
									<div style="text-align: center; width: 120px;" class=""><gt name="list.finish_time" value="0">{$list.finish_time|date='Y-m-d H:i',###}</gt></div>
								</td>
								<td align="center" abbr="article_time" axis="col6" class="" >
									<div style="text-align: left;" class=""><span style="color: red">{$list.preference}</span></div>
								</td>
								<td align="left" axis="col1" class="handle" align="center">
									<div style="text-align: left; ">
										<a class="btn green" href="{:url('order/detail',array('order_id'=>$list['id']))}"><i class="fa fa-list-alt"></i>查看</a>
									<eq name="$list['status']" value="1">
										<a data-url="{:url('order/deal')}" data-id="{$list['id']}" onclick="dealfun(this)" class="btn blue"><i class="fa fa-pencil-square-o"></i>开始处理</a>
									</eq>
									</div>
								</td>
							</tr>
						</volist>
					</if>
					</tbody>
				</table>
				<div class="row">
					<div class="col-sm-6 text-left"></div>
					<div class="col-sm-6 text-right"></div>
				</div>
				<script>
					$(".pagination  a").click(function(){
						var page = $(this).data('p');
						ajax_get_table('search-form2',page);
					});

					$('.ftitle>h5').empty().html("(共{$count}条记录)");
				</script>
			</div>
			<div class="iDiv" style="display: none;"></div>
		</div>
		<!--分页位置-->
		{$page}
	</div>
</div>
<script type="text/javascript" src="__STATIC__/admin/js/laydate/laydate.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		laydate({
			elem: '#add_time_begin', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
			format: 'YYYY-MM-DD hh:mm:ss',//YYYY/MM/DD hh:mm:ss
			istime: true,
			event: 'focus' //响应事件。如果没有传入event，则按照默认的click
		});
		laydate({
			elem: '#add_time_end', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
			format: 'YYYY-MM-DD hh:mm:ss',//YYYY/MM/DD hh:mm:ss
			istime: true,
			event: 'focus' //响应事件。如果没有传入event，则按照默认的click
		});
		// 点击刷新数据
		$('.pReload').click(function(){
			window.location.reload()
		});
		$('#flexigrid > table>tbody >tr').click(function(){
			$(this).toggleClass('trSelected');
		});
		$('.hDivBox .ico-check').click(function(){
			$('tr').toggleClass('trSelected' , function(index,currentclass){
				var hasClass = $(this).hasClass('trSelected');
				$('tr' , '#flexigrid').each(function(){
					if(hasClass){
						$(this).addClass('trSelected');
					}else{
						$(this).removeClass('trSelected');
					}
				});
			});
		});
	});
	// 点击排序
	function sort(field){
		$("input[name='order_by']").val(field);
		var v = $("input[name='sort']").val() == 'desc' ? 'asc' : 'desc';
		$("input[name='sort']").val(v);
		ajax_get_table('search-form2',cur_page);
	}
	function dealfun(obj) {
		// 删除按钮

		$.ajax({
			type: 'post',
			url: $(obj).attr('data-url'),
			data: {id: $(obj).attr('data-id')},
			dataType: 'json',
			success: function (data) {
				if (data == 1) {
					window.location.reload();
				} else {
					layer.alert(data, {icon: 2});  //alert('删除失败');
				}
			}
		})
	}
	function exportReport(){
		var selected_ids = '';
		$('.trSelected' , '#flexigrid').each(function(i){
			selected_ids += $(this).data('order-id')+',';
		});
		if(selected_ids != ''){
			$('input[name="order_ids"]').val(selected_ids.substring(0,selected_ids.length-1));
		}
		$('#search-form2').submit();
	}


</script>
</body>
</html>